<?php


namespace chixian\Libraries\Exception;


use Hyperf\Server\Exception\ServerException;
use Throwable;

/**
 * 异常基类
 * Class BaseException
 * @package chixian\Libraries\Exception
 */
class BaseException extends ServerException
{
    /** @var int 状态码 */
    protected int $recode = 10100;

    /** @var array 回应数据 */
    protected array $data = [];

    public function __construct($message = "", $code = 0, Throwable $previous = null, int $recode = 0, array $data = [])
    {
        parent::__construct($message, $code, $previous);
        empty($recode) || $this->recode = $recode;
        empty($data) || $this->data = $data;
    }

    /**
     * @return int
     */
    public function getRecode(): int
    {
        return $this->recode;
    }

    /**
     * @param int $recode
     */
    public function setRecode(int $recode): void
    {
        $this->recode = $recode;
    }

    /**
     * @return array
     */
    public function getData(): array
    {
        return $this->data;
    }

    /**
     * @param array $data
     */
    public function setData(array $data): void
    {
        $this->data = $data;
    }
}